package com.soft.cake.utils;

import java.util.Date;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;


public class DateUtil {
	 	/**
	     * @description 将Date转换成String
	     * @param date
	     * @return  guoxue
	     */
	    public static String date2String(Date date) {
	        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
	        String dateStr = sdf.format(date);
	        return dateStr;
	    }	
	    
	    /**
	     * @description 将短时间格式字符串转换为时间 yyyy-MM-dd
	     * @param date
	     * @return  guoxue
	     */
	    public static Date strToDate(String strDate) {
	       SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
	       ParsePosition pos = new ParsePosition(0);
	       Date strtodate = formatter.parse(strDate, pos);
	       return strtodate;
	     }
}
